home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / MC220.ARJ / CTYPE.H < prev    next >
C/C++ Source or Header  |  1992-02-24  |  2KB  |  39 lines

  1. /*
  2.  * Character classification macros for MICRO-C
  3.  *
  4.  * These macros classify the passed character based on a table
  5.  * lookup. The accepted range of character values which may be
  6.  * tested is (0 to 127, and EOF).
  7.  *
  8.  * NOTE: Since these are "parameterized" macros, they MUST be
  9.  *       processed by the external pre-processor (MCP). If you
  10.  *       are using the internal processor do not include this
  11.  *       file, and library functions will be used instead.
  12.  *
  13.  * Copyright 1990,1992 Dave Dunfield
  14.  * All rights reserved.
  15.  */
  16.  
  17. /* Type bits in _chartype_ */
  18. #define IS_CTL    0x01        /* Control code */
  19. #define IS_SPC    0x02        /* Space character */
  20. #define IS_DIG    0x04        /* Numeric digit */
  21. #define IS_UPP    0x08        /* Upper-case alphabetic */
  22. #define IS_LOW    0x10        /* Lower-case alphabetic */
  23. #define IS_HEX    0x20        /* Valid hex-alphabetic character */
  24. #define IS_PUN    0x40        /* Non-graphic printable character */
  25.  
  26.     extern char _chartype_[];
  27.  
  28. /* Character classification macros */
  29. #define    iscntrl(c)    (_chartype_[(c)+1] & IS_CTL)
  30. #define    isspace(c)    (_chartype_[(c)+1] & IS_SPC)
  31. #define    isdigit(c)    (_chartype_[(c)+1] & IS_DIG)
  32. #define    isupper(c)    (_chartype_[(c)+1] & IS_UPP)
  33. #define    islower(c)    (_chartype_[(c)+1] & IS_LOW)
  34. #define    ispunct(c)    (_chartype_[(c)+1] & IS_PUN)
  35. #define    isalpha(c)    (_chartype_[(c)+1] & (IS_UPP | IS_LOW))
  36. #define    isxdigit(c)    (_chartype_[(c)+1] & (IS_DIG | IS_HEX))
  37. #define    isalnum(c)    (_chartype_[(c)+1] & (IS_DIG | IS_UPP | IS_LOW))
  38. #define    isgraph(c)    (_chartype_[(c)+1] & (IS_PUN | IS_DIG | IS_UPP | IS_LOW))
  39.